﻿namespace Sai.Core
{
	using System.Xml.Serialization;
    using Sai.Core.Introspection;

	/// <summary>
	/// Used to tie a fully qualified type name to the types Id
	/// </summary>
	public class TypeNameReference
	{
		private Identifier ident = new Identifier();

		public TypeNameReference()
		{
		}

		public TypeNameReference(string name, string namespaceName, string guid)
		{
            this.TypeName = name;
            this.FullName = name.FullyQualifyName(namespaceName);
			this.Identifier = guid;
		}

		[XmlAttribute("ID")]
		public string Identifier
		{
			get
			{
				return this.ident.Value;
			}

			set
			{
				this.ident = new Identifier(value);
			}
		}

		[XmlAttribute("TypeName")]
		public string TypeName
		{
			get;
			set;
		}

        [XmlAttribute("FullName")]
        public string FullName
        {
            get;
            set;
        }

        [XmlAttribute("SafeName")]
        public string SafeName
        {
            get
            {
                return this.FullName.Replace("<", "").Replace(">", "");
            }
            set
            {
                this.FullName = value;
            }
        }

	}
}
